let { auditList, list } = require('./mock')
const bodyParser = require('body-parser')
module.exports = app => {
	app.use(bodyParser.json())

	app.get('/api/audit/list', (req, res) => {
		const { type } = req.query;
		const newList = auditList.filter(v => {
			if (type === '全部') return true
			return type === v.type
		})
		res.send({
			code: 200,
			data: newList
		})
	})

	app.post('/api/audit', (req, res) => {
		const { key } = req.body

		const list1 = auditList.filter(v => key.includes(v.key))

		const list2 = auditList.filter(v => !key.includes(v.key))

		console.log(list1, list2);

		auditList = list2
		list = [...list, ...list1]
		res.send({
			code: 200,
			mess: '审核成功！'
		})
	})

	app.get('/api/list', (req, res) => {
		res.send({
			code: 200,
			data: list
		})
	})
}